using SharePoint.Security.ConfigAnalyzer.Engine.Base;
using SharePoint.Security.ConfigAnalyzer.Engine.Common;
using Microsoft.SharePoint.Administration;

namespace SharePoint.Security.ConfigAnalyzer.Engine.Rules.Diagnostic
{
    public class EventLogFloodProtection : BaseRule
    {
        public EventLogFloodProtection()
        {
            RuleInfo = new RuleInfo
                           {
                               Title = "Event log flood protection",
                               Description = "Event Log Flood Protection is turned on (Central Admin > Diagnostic Logging > Metrics.aspx)",
                               ExpectedValue = "True"
                           };
        }

        #region Overrides of BaseRule

        public override void Validate()
        {
            SPDiagnosticsService diagSvc = ObjectHelper.Diagnostics;

            if (diagSvc.EventLogFloodProtectionEnabled)
            {
                Status = Status.Pass;
            }
            else
            {
                Status = Status.Fail;
            }

            CurrentValue = diagSvc.EventLogFloodProtectionEnabled.ToString();
        }

        #endregion
    }
}